<template>
  <div id="index" v-loading.fullscreen.lock="fullscreenLoading"
              element-loading-text="拼命加载中"
    element-loading-spinner="el-icon-loading"
    element-loading-background="rgba(0, 0, 0, 0.2)">
    <el-container>
      <el-header height="100px">
        <div class="flexbox" style="width:100%;">
          <div class="logo">
             <router-link to="/"><img src="./assets/zgs_log.png" width="100%"></router-link>
          </div>
          <div class="nav">
            <el-breadcrumb separator="|" v-if="status">
              <el-breadcrumb-item>欢迎您: {{userName}}</el-breadcrumb-item>   
              <el-breadcrumb-item ><span @click="logout">退出</span></el-breadcrumb-item>
            </el-breadcrumb>
            <el-breadcrumb separator="|" v-else>
              <el-breadcrumb-item>说明</el-breadcrumb-item>
              <el-breadcrumb-item><router-link to="/register">注册</router-link></el-breadcrumb-item>
              <el-breadcrumb-item><router-link to="/login">登录</router-link></el-breadcrumb-item>
            </el-breadcrumb>
          </div>
        </div>
      </el-header>
      <el-main>
        <el-carousel height="400px">
          <el-carousel-item v-for="item in pictures" :key="item.path">
            <img :src="item.path" width="100%" height="100%">
          </el-carousel-item>
        </el-carousel>
        <div class="container">
          <h3 class="step_tip">报名流程</h3>
          <div class="process">
            <el-steps  align-center>
              <el-step title="进入报名系统" icon="el-icon-setting"></el-step>
              <el-step title="填写基本信息" icon="el-icon-edit"></el-step>
              <el-step title="邮寄资料" icon="el-icon-message"></el-step>
              <el-step title="审查" icon="el-icon-question"></el-step>
              <el-step title="笔试" icon="el-icon-edit-outline"></el-step>
              <el-step title="面试" icon="el-icon-service"></el-step>
              <el-step title="查询成绩" icon="el-icon-search"></el-step>
            </el-steps>
          </div>
          <el-button type="primary" @click="gotoLogin">进入报名系统</el-button>
        </div>
        <div class="noticeDiv">
            <div class="container">
              <ul class="site-idea">
                <li>
                    <p class="swyt">三位一体</p>
                    <el-tabs v-model="tab1" type="border-card" @tab-click="handleClick1">
                      <el-tab-pane label="通知公告" name="Sfirst" style="height: 245px">
                        <dt>
                          <template v-for="item in gg1">
                            <dl>
                              <router-link :to="{path:'/noticeDetail',query:{id:item.id}}">
                                <p class="top">
                                  <span class="noticeTitle"><i class="el-icon-menu"></i>&nbsp;{{item.title}}</span>
                                  <span style="display: inline-block;overflow:hidden;"><i class="el-icon-location" style="color:#409EFF;" v-if="item.istop"></i></span>
                                </p>
                              </router-link>
                              <span style="float:right"></i>{{item.modified}}</span>
                            </dl>
                          </template>
                        </dt>
                        <p class="more"><router-link :to="{path:'/notice',query:{id:swyt1}}"><i class="el-icon-d-arrow-right"></i>更多</router-link></p>
                      </el-tab-pane>
                      <el-tab-pane label="报考指南" name="Ssecond" style="height: 245px">
                        <dt>
                          <template v-for="item in zn1">
                            <dl>
                              <router-link :to="{path:'/noticeDetail',query:{id:item.id}}">
                                <p class="top">
                                  <span class="noticeTitle"><i class="el-icon-menu"></i>&nbsp;{{item.title}}</span>
                                  <span style="display: inline-block;overflow:hidden;"><i class="el-icon-location" style="color:#409EFF;" v-if="item.istop"></i></span>
                                </p>
                              </router-link>
                              <span style="float:right"></i>{{item.modified}}</span>
                            </dl>
                          </template>
                        </dt>
                        <p class="more"><router-link :to="{path:'/notice',query:{id:swyt2}}"><i class="el-icon-d-arrow-right"></i>更多</router-link></p>
                      </el-tab-pane>
                    </el-tabs>
                </li>
                <li>
                    <p class="zxs">高水平运动员</p>
                    <el-tabs v-model="tab2" type="border-card" @tab-click="handleClick2">
                      <el-tab-pane label="通知公告" name="Gfirst" style="height: 245px">
                        <dt>
                          <template v-for="item in gg2">
                            <dl>
                              <router-link :to="{path:'/noticeDetail',query:{id:item.id}}">
                                <p class="top">
                                  <span class="noticeTitle"><i class="el-icon-menu"></i>&nbsp;{{item.title}}</span>
                                  <span style="display: inline-block;overflow:hidden;"><i class="el-icon-location" style="color:#409EFF;" v-if="item.istop"></i></span>
                                </p>
                              </router-link>
                              <span style="float:right"></i>{{item.modified}}</span>
                            </dl>
                          </template>
                        </dt>
                        <p class="more"><router-link :to="{path:'/notice',query:{id:zxs1}}"><i class="el-icon-d-arrow-right"></i>更多</router-link></p>
                      </el-tab-pane>
                      <el-tab-pane label="报考指南" name="Gsecond" style="height: 245px">
                        <dt>
                          <template v-for="item in zn2">
                            <dl>
                              <router-link :to="{path:'/noticeDetail',query:{id:item.id}}">
                                <p class="top">
                                  <span class="noticeTitle"><i class="el-icon-menu"></i>&nbsp;{{item.title}}</span>
                                  <span style="display: inline-block;overflow:hidden;"><i class="el-icon-location" style="color:#409EFF;" v-if="item.istop"></i></span>
                                </p>
                              </router-link>
                              <span style="float:right"></i>{{item.modified}}</span>
                            </dl>
                          </template>
                        </dt>
                        <p class="more"><router-link :to="{path:'/notice',query:{id:zxs2}}"><i class="el-icon-d-arrow-right"></i>更多</router-link></p>
                      </el-tab-pane>
                    </el-tabs>
                </li>
              </ul>
              
            </div>
        </div>
        <footer>
          @copyright
        </footer>
      </el-main>
    </el-container>
  </div>
</template>

<script>
export default {
  name: 'HelloWorld',
  data () {
    return {
      //登录状态
      status:false,
      userName:'',
      tab1:'Sfirst',
      tab2:'Gfirst',
      pictures:[],
      swyt1:'',
      swyt2:'',
      zxs1:'',
      zxs2:'',
      gg1:[],
      gg2:[],
      zn1:[],
      zn2:[],
      fullscreenLoading:false
    }

  },
  mounted(){
    this.getInfo();
    this.getNoticeInfo();
  },
  methods:{
    getInfo(){
      var that=this;
      let user = JSON.parse(window.sessionStorage.getItem('access-user'))
      if (!user){
        this.status=false;
      }else{
        this.status=true;
        this.fullscreenLoading=true;
        this.axios({
          url:this.host+'/3v1t.smserver.cn/index.php/student/Modifysysinfo/getinfo',
          method:'post',
          headers:{
                "Content-type":"application/json"
              }

        }).then((res)=>{
          //console.log(res);
          this.fullscreenLoading=false;
          that.userName=res.data.data.account;
        })
      }
    },
    logout(){
      var that=this;
      this.axios({
            url:this.host+'/3v1t.smserver.cn/index.php/index/login/signout',
            method:'post',
            headers:{
              "Content-type":"application/json"
            }
          }).then((res)=>{
            console.log(res);            
            sessionStorage.clear();
            //that.$router.push("/");
            that.status=false;
          })
    },
    gotoLogin(){
      this.$router.push("/userHome");
    },
    getNoticeInfo(){
      var that=this;
      this.fullscreenLoading=true;
      this.axios({
          url:this.host+'/3v1t.smserver.cn/index.php/index/index',
          method:'post',
          headers:{
                "Content-type":"application/json"
              }

        }).then((res)=>{
          console.log(res);
          this.fullscreenLoading=false;
          var data=res.data.data
          data.swyt.zn.data.forEach((item)=>{
            if(item.istop==1){
              item.istop=true;
            }else{
              item.istop=false;
            }
            item.modified=item.modified.split(" ")[0]
          })
          data.swyt.gg.data.forEach((item)=>{
            if(item.istop==1){
              item.istop=true;
            }else{
              item.istop=false;
            }
            item.modified=item.modified.split(" ")[0]
          })
          data.zxs.gg.data.forEach((item)=>{
            if(item.istop==1){
              item.istop=true;
            }else{
              item.istop=false;
            }
            item.modified=item.modified.split(" ")[0]
          })
          data.zxs.zn.data.forEach((item)=>{
            if(item.istop==1){
              item.istop=true;
            }else{
              item.istop=false;
            }
            item.modified=item.modified.split(" ")[0]
          })
          that.pictures=data.slide
          that.swyt1= data.swyt.gg.id
          that.swyt2= data.swyt.zn.id
          that.zxs1= data.zxs.gg.id
          that.zxs2= data.zxs.zn.id
          that.gg1= data.swyt.gg.data;
          that.gg2= data.zxs.gg.data;
          that.zn1= data.swyt.zn.data;
          that.zn2= data.zxs.zn.data
          console.log(that.zxs);
          
        })    
    },
    handleClick1(tab, event) {
       
        console.log(this.tab1)
    },
    handleClick2(tab, event) {
        //console.log(tab);
        console.log(this.tab1)
    }
  }
}
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style lang="scss">
#index{
  .container{
    width:1080px;
    margin:0 auto;
  }
  header{
      height:100px;
      background:#393D49;
      display:flex;
      align-items: center;
      border-bottom: 1px solid rgba(255,255,255,0.3);
      .flexbox{
        display:flex;
        align-items: center;
        justify-content: space-between;
      }
  }
    footer{
    height:60px;
    text-align:center;
    line-height:60px;
    color:#fff;
    font-size:14px;
    background:#393D49;
 }
  .logo{
    width:500px;
  }
  .nav a,.nav span{
    color:#fff;
    cursor: pointer;
    text-decoration:none;
  }
  .process{
    margin:30px 0;
  }
  .step_tip {
    font-size: 24px;
    color: #404549;
    line-height: 26px;
    text-align: center;
    font-weight: 400;
    margin-bottom: 14px;
    margin-top: 20px;
  }
  .noticeDiv{
    width:100%;
    //background: #f4f4f4;
    padding:40px 0;
    a {
        color: #333;
        text-decoration: none;
    }
  }
  .site-idea{font-size: 0; text-align: center; font-weight: 300; padding: 0;display: flex;justify-content: space-between; margin:20px;}
  .site-idea li{position:relative;display: inline-block; vertical-align: top; *display: inline; *zoom:1; font-size: 14px; }
  .site-idea li{width: 50%;line-height: 24px; margin-left: 30px; text-align: left;}
  .site-idea li:first-child{margin-left: 0}
  .zxs,.swyt{
    position:absolute;
    color:#409EFF;
    top:10px;
    left:20px;
    font-weight: 400;
    font-size: 16px;
    z-index:9;
  }
  .more{
    position:absolute;
    color:#409EFF;
    bottom:6px;
    right:20px;
    font-size:12px;
    cursor:pointer;
    z-index:9;
     a{
    color:#409EFF;
    }
  }
  .site-idea .layui-field-title{border-color: #d2d2d2}
  .site-idea .layui-field-title legend{ padding: 0 20px; text-align: center;}
  .site-idea dt{margin:0 10px }
  .site-idea dl{
    line-height:30px;
  }
  .noticeTitle{
    max-width:340px;
    display: inline-block;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
  }
  .top{
    display: inline-block;
    //overflow:hidden;
  }
  
  .layui-field-title {
    margin: 10px 0 10px;
    border-width: 1px 0 0;
  }
  .layui-elem-field legend {
    //margin-left: 20px;
    //padding: 0 10px;
    font-size: 20px;
    font-weight: 300;
  }
  .layui-elem-field {
    //margin-bottom: 10px;
    padding: 0;
    //border-width: 1px;
    border-style: solid;
  }
  .el-step__head.is-wait,.el-step__title.is-wait{
    color:#333
  }
  .el-main{
    padding:0;
    overflow:hidden;
  }
  .el-tabs__nav{
    float:right;
  }
  .el-tabs__header{
    margin:0 0 5px;
  }
  .el-tabs--border-card>.el-tabs__header .el-tabs__item.is-active{
    border-top-color: #dcdfe6;
  }
  .el-tabs--border-card>.el-tabs__header .el-tabs__item {
    margin: 5px 10px 0;
  }
  .el-tabs--border-card>.el-tabs__content {
    padding: 10px 10px 25px 10px;
  }
  .el-tabs--border-card{
    height:320px;
  }
  .el-tabs__item{
    padding:0 10px;
    height:35px;
    line-height:35px;
  }
  
  
}
</style>
